package po;

import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;

import javax.imageio.ImageIO;

public class ValidatePO implements Serializable{
	private static final long serialVersionUID = 1L;
	private byte[] imageData;
	private String validateCode;
	public static final int VALIDATEIMAGE_WIDTH=100;
	public static final int VALIDATEIMAGE_HEIGHT=50;
	
	public ValidatePO (byte[] imageData,String validateCode){
		this.imageData=imageData;
		this.validateCode=validateCode;
	}
	
	public boolean isValidateCorrect(String validateCode){
		return this.validateCode.equalsIgnoreCase(validateCode);
	}
	
	

	public Image getValidateImage() {
		if (imageData == null) {
			return null;
		}
		 
		try {
			ByteArrayInputStream bais = new ByteArrayInputStream(imageData);
			return ImageIO.read(bais);
		} catch (IOException ex) {
			return null;
		}
	}

	
}
